package com.example.redismanual.dao.actionExamples;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;


// 使用redis实现缓存
public class Cache {

    private ValueOperations<String, String> client;

    public Cache(ValueOperations<String, String> client) {
            this.client  = client;
    }

    public void set(String key, String value) {
        this.client.set(key, value);
    }

    public String get(String key) {
        return this.client.get(key);
    }

    public String update(String key, String value) {
        return this.client.getAndSet(key, value);
    }

}
